from django.contrib.admin import SimpleListFilter


class StatusFilter(SimpleListFilter):
    title = 'status'
    parameter_name = 'status'

    def lookups(self, request, model_admin):
        return [(1, '未关灯'), (2, '已关灯')]

    def queryset(self, request, queryset):
        # this_day = datetime.date.today()
        # pdb.set_trace()
        if self.value() == '1':
            return queryset.filter(end_time__isnull=True)
        elif self.value() == '2':
            return queryset.filter(end_time__isnull=False)
